home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 43 / Mac Magazin and MacEasy Magazine CD - Issue 43.iso / Software / Mobiles Büro / Newton / Newton Entwickler / DIL 2.0 Sample Code ƒ / SoupDrink-Mac-4 / console.stubs.c < prev    next >
Text File  |  1995-07-22  |  3KB  |  111 lines

  1. /************************************************************************/
  2. /*    Project...:    Standard ANSI-C Library                                    */
  3. /*    Name......:    console.c                                                */
  4. /*    Purpose...:    Stubs for console.c                                        */
  5. /*  Copyright.: ©Copyright 1994 by metrowerks inc. All rights reserved. */
  6. /************************************************************************/
  7.  
  8. #ifndef __CONSOLE__
  9. #include <console.h>
  10. #endif
  11.  
  12. /*
  13.  *    The following four functions provide the UI for the console package.
  14.  *    Users wishing to replace SIOUX with their own console package need
  15.  *    only provide the four functions below in a library.
  16.  */
  17.  
  18. /*
  19.  *    extern short InstallConsole(short fd);
  20.  *
  21.  *    Installs the Console package, this function will be called right
  22.  *    before any read or write to one of the standard streams.
  23.  *
  24.  *    short fd:        The stream which we are reading/writing to/from.
  25.  *    returns short:    0 no error occurred, anything else error.
  26.  */
  27.  
  28. short InstallConsole(short fd)
  29. {
  30. #pragma unused (fd)
  31.  
  32.     return 0;
  33. }
  34.  
  35. /*
  36.  *    extern void RemoveConsole(void);
  37.  *
  38.  *    Removes the console package.  It is called after all other streams
  39.  *    are closed and exit functions (installed by either atexit or _atexit)
  40.  *    have been called.  Since there is no way to recover from an error,
  41.  *    this function doesn't need to return any.
  42.  */
  43.  
  44. void RemoveConsole(void)
  45. {
  46. }
  47.  
  48. /*
  49.  *    extern long WriteCharsToConsole(char *buffer, long n);
  50.  *
  51.  *    Writes a stream of output to the Console window.  This function is
  52.  *    called by write.
  53.  *
  54.  *    char *buffer:    Pointer to the buffer to be written.
  55.  *    long n:            The length of the buffer to be written.
  56.  *    returns short:    Actual number of characters written to the stream,
  57.  *                    -1 if an error occurred.
  58.  */
  59.  
  60. long WriteCharsToConsole(char *buffer, long n)
  61. {
  62. #pragma unused (buffer, n)
  63.  
  64.     return 0;
  65. }
  66.  
  67. /*
  68.  *    extern long ReadCharsFromConsole(char *buffer, long n);
  69.  *
  70.  *    Reads from the Console into a buffer.  This function is called by
  71.  *    read.
  72.  *
  73.  *    char *buffer:    Pointer to the buffer which will recieve the input.
  74.  *    long n:            The maximum amount of characters to be read (size of
  75.  *                    buffer).
  76.  *    returns short:    Actual number of characters read from the stream,
  77.  *                    -1 if an error occurred.
  78.  */
  79.  
  80. long ReadCharsFromConsole(char *buffer, long n)
  81. {
  82. #pragma unused (buffer, n)
  83.  
  84.     return 0;
  85. }
  86.  
  87. /*
  88.  *    extern char *__ttyname(long fildes);
  89.  *
  90.  *    Return the name of the current terminal (only valid terminals are
  91.  *    the standard stream (ie stdin, stdout, stderr).
  92.  *
  93.  *    long fildes:    The stream to query.
  94.  *
  95.  *    returns char*:    A pointer to static global data which contains a C string
  96.  *                    or NULL if the stream is not valid.
  97.  */
  98.  
  99. extern char *__ttyname(long fildes)
  100. {
  101. #pragma unused (fildes)
  102.     /* all streams have the same name */
  103.     static char *__devicename = "null device";
  104.  
  105.     if (fildes >= 0 && fildes <= 2)
  106.         return (__devicename);
  107.  
  108.     return (0L);
  109. }
  110.  
  111.